import 'package:flutter/material.dart';
import 'package:flutter_project/config/app_bar_view.dart';
import 'package:get/get.dart';
import '../generated/l10n.dart';
import '../user/collect/my_collect_list_page.dart';
import 'my_work_tab_page.dart';

class PictureMainPage extends StatefulWidget {
  const PictureMainPage({super.key});

  @override
  State<PictureMainPage> createState() => _PictureMainPageState();
}

class _PictureMainPageState extends State<PictureMainPage>
    with SingleTickerProviderStateMixin {
  late TabController importTabController;
  List<String> tabList = ['作品', '收藏'];
  double tabFontSize = 16.0;

  @override
  Widget build(BuildContext context) {
    return CommonAppWidget.navAppDrawBar(
        context: context,
        bgColor: Colors.white,
        title: S.of(context).my,
        childWidget: Column(
          children: [
            SizedBox(
              height: 40,
              child: TabBar(
                tabs: getTabList(),
                controller: importTabController,
                // labelColor: ThemeColor.black3D3D3DColor,
                // unselectedLabelColor: ThemeColor.grayA0A0A0Color,
                indicatorSize: TabBarIndicatorSize.label,
                // indicatorColor: ThemeColor.appColor,
                unselectedLabelStyle: TextStyle(
                  fontSize: tabFontSize,
                ),
                // 未选择样式
                labelStyle: TextStyle(
                    fontSize: tabFontSize,
                    fontWeight: FontWeight.w500), // 选择的样式
              ),
            ),
            Expanded(
              child:
                  TabBarView(controller: importTabController, children: const [
                MyWorkTabPage(),
                MyCollectListPage(),
              ]),
            ),
          ],
        ));
  }

  //组装tab
  List<Widget> getTabList() {
    List<Widget> list =
        List.generate(tabList.length, (index) => Tab(text: tabList[index]));
    return list;
  }

  @override
  void initState() {
    super.initState();
    tabList = [S.of(Get.context!).works, S.of(Get.context!).collect];
    importTabController = TabController(length: tabList.length, vsync: this);
  }
}
